<?php
namespace  Android\Model;
use Think\Model;

class FollowModel extends Model
{
//关注的作者
    function followdetails(&$user_id){
        $array=[];
        $info=M('Follow');
        //获取关注作者的信息
        $authorinfo=$info->alias('fo')->join('user us on fo.focus_id=us.user_id')->field('us.nickname,head_img')->where('fo.type=2 and fo.user_id='.$user_id)->select();
        //关注的店铺的信息
        $shopinfo=$info->alias('fo')->join('shop sh on fo.focus_id=sh.shop_id')->field('sh.shop_name,sh.shop_id,sh.shop_logo,sh.intro')->where('fo.type=1')->select();
        $shop=D('shop');
        foreach ($shopinfo as $key => $value) {
            $shopid=$value['shop_id'];
            $infooo= $shop->join('activity ac on ac.shop_id=shop.shop_id')->field('act_id,theme')->where('shop.shop_id='. $shopid)->order('gene_time')->limit(1)->find();
            $shopinfo[$key][act]=$infooo;
        }
        //查看关注的网站
        $web= $info->alias('fo')->join('website we on fo.focus_id=we.id')->field('we.*')->where('fo.type=2 and fo.user_id='.$user_id)->select();
        $array['shop']= $shopinfo?$shopinfo:'';
        $array['web']=$web?$web:'';
        $array['auth']=$authorinfo;
        return $array ;
    }
}

